<!DOCTYPE html>

















































<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="description" content="Javadoc API documentation for Dormancy." />

<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>

  JpaProviderUtils


| Dormancy

</title>
<link href="../../../../assets/doclava-developer-docs.css" rel="stylesheet" type="text/css" />
<link href="../../../../assets/customizations.css" rel="stylesheet" type="text/css" />
<script src="../../../../assets/search_autocomplete.js" type="text/javascript"></script>
<script src="../../../../assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="../../../../assets/doclava-developer-docs.js" type="text/javascript"></script>
<script src="../../../../assets/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
  setToRoot("../../../", "../../../../assets/");
</script>
<script src="../../../../assets/doclava-developer-reference.js" type="text/javascript"></script>
<script src="../../../../assets/navtree_data.js" type="text/javascript"></script>
<script src="../../../../assets/customizations.js" type="text/javascript"></script>
<noscript>
  <style type="text/css">
    html,body{overflow:auto;}
    #body-content{position:relative; top:0;}
    #doc-content{overflow:visible;border-left:3px solid #666;}
    #side-nav{padding:0;}
    #side-nav .toggle-list ul {display:block;}
    #resize-packages-nav{border-bottom:3px solid #666;}
  </style>
</noscript>
</head>

<body class="">

<div id="header">
    <div id="headerLeft">
    
      <span id="masthead-title">Dormancy</span>
    
    </div>
    <div id="headerRight">
      
  <div id="search" >
      <div id="searchForm">
          <form accept-charset="utf-8" class="gsc-search-box" 
                onsubmit="return submit_search()">
            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
                <tr>
                  <td class="gsc-input">
                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../')"
                      onkeyup="return search_changed(event, false, '../../../')" />
                  <div id="search_filtered_div" class="no-display">
                      <table id="search_filtered" cellspacing=0>
                      </table>
                  </div>
                  </td>
                  <td class="gsc-search-button">
                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
                  </td>
                  <td class="gsc-clear-button">
                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
                  </td>
                </tr></tbody>
              </table>
          </form>
      </div><!-- searchForm -->
  </div><!-- search -->
      
    </div>
</div><!-- header -->


  <div class="g-section g-tpl-240" id="body-content">
    <div class="g-unit g-first side-nav-resizable" id="side-nav">
      <div id="swapper">
        <div id="nav-panels">
          <div id="resize-packages-nav">
            <div id="packages-nav">
              <div id="index-links"><nobr>
                <a href="../../../packages.html"  >Package Index</a> | 
                <a href="../../../classes.html" >Class Index</a></nobr>
              </div>
              <ul>
                
    <li class="api apilevel-">
  <a href="../../../at/dormancy/package-summary.html">at.dormancy</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/access/package-summary.html">at.dormancy.access</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/aop/package-summary.html">at.dormancy.aop</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persistence/package-summary.html">at.dormancy.persistence</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persister/package-summary.html">at.dormancy.persister</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persister/callback/package-summary.html">at.dormancy.persister.callback</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persister/filter/package-summary.html">at.dormancy.persister.filter</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persister/function/package-summary.html">at.dormancy.persister.function</a></li>
    <li class="api apilevel-">
  <a href="../../../at/dormancy/persister/predicate/package-summary.html">at.dormancy.persister.predicate</a></li>
    <li class="selected api apilevel-">
  <a href="../../../at/dormancy/util/package-summary.html">at.dormancy.util</a></li>
              </ul><br/>
            </div> <!-- end packages -->
          </div> <!-- end resize-packages -->
          <div id="classes-nav">
            <ul>
              
              
    <li><h2>Classes</h2>
      <ul>
          <li class="api apilevel-"><a href="../../../at/dormancy/util/AbstractDormancyUtils.html">AbstractDormancyUtils</a>&lt;PU,&nbsp;PC,&nbsp;PMD,&nbsp;PUP&nbsp;extends&nbsp;<a href="../../../at/dormancy/persistence/PersistenceUnitProvider.html">PersistenceUnitProvider</a>&lt;PU,&nbsp;PC,&nbsp;PMD&gt;&gt;</li>
          <li class="api apilevel-"><a href="../../../at/dormancy/util/ClassLookup.html">ClassLookup</a></li>
          <li class="api apilevel-"><a href="../../../at/dormancy/util/DormancyUtils.html">DormancyUtils</a></li>
          <li class="api apilevel-"><a href="../../../at/dormancy/util/IntrospectorUtils.html">IntrospectorUtils</a></li>
          <li class="selected api apilevel-"><a href="../../../at/dormancy/util/JpaProviderUtils.html">JpaProviderUtils</a></li>
      </ul>
    </li>
              
              
              
              
            </ul><br/>
          </div><!-- end classes -->
        </div><!-- end nav-panels -->
        <div id="nav-tree" style="display:none">
          <div id="index-links"><nobr>
            <a href="../../../packages.html"  >Package Index</a> | 
            <a href="../../../classes.html" >Class Index</a></nobr>
          </div>
        </div><!-- end nav-tree -->
      </div><!-- end swapper -->
    </div> <!-- end side-nav -->
    <script>
      if (!isMobile) {
        $("<a href='#' id='nav-swap' onclick='swapNav();return false;' style='font-size:10px;line-height:9px;margin-left:1em;text-decoration:none;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>").appendTo("#side-nav");
        chooseDefaultNav();
        if ($("#nav-tree").is(':visible')) {
          init_default_navtree("../../../");
        } else {
          addLoadEvent(function() {
            scrollIntoView("packages-nav");
            scrollIntoView("classes-nav");
          });
        }
        $("#swapper").css({borderBottom:"2px solid #aaa"});
      } else {
        swapNav(); // tree view should be used on mobile
      }
    </script>



<div class="g-unit" id="doc-content">

<div id="api-info-block">



  
   
  
  
  
  


<div class="sum-details-links">

<div>
<a href="JpaProviderUtils.html">View Documentation</a>
</div>


</div><!-- end sum-details-links -->
<div class="api-level">
  


  
  

</div>
</div><!-- end api-info-block -->


<!-- ======== START OF CLASS DATA ======== -->

<div id="jd-header">
    public
     
     
    
    class
<h1>JpaProviderUtils</h1>



  
    extends <a href="http://download.oracle.com/javase/6/docs/api/index.html?java/lang/Object.html">Object</a><br/>
  
  
  

  
  
  


</div><!-- end header -->
<div id="jd-content">
  <pre class="prettyprint">
/*
 * Copyright 2013 Gregor Schauer
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package at.dormancy.util;

import javax.annotation.Nonnull;

/**
 * Utilities for making JPA providers compatible.
 * &lt;p/&gt;
 * They attempts to load the collection classes regardless of the implementation and version present in the classpath.
 * &lt;p/&gt;
 * Currently, the following JPA providers are supported:
 * &lt;ul&gt;
 *     &lt;li&gt;Hibernate 3&lt;/li&gt;
 *     &lt;li&gt;Hibernate 4&lt;/li&gt;
 *     &lt;li&gt;EclipseLink&lt;/li&gt;
 * &lt;/ul&gt;
 *
 * @author Gregor Schauer
 * @since 2.0.0
 */
public class JpaProviderUtils {
	protected static final String HIBERNATE_3_COLLECTION = "org.hibernate.collection.PersistentCollection";
	protected static final String HIBERNATE_3_LIST = "org.hibernate.collection.PersistentList";
	protected static final String HIBERNATE_3_SET = "org.hibernate.collection.PersistentSet";
	protected static final String HIBERNATE_3_MAP = "org.hibernate.collection.PersistentMap";

	protected static final String HIBERNATE_4_COLLECTION = "org.hibernate.collection.spi.PersistentCollection";
	protected static final String HIBERNATE_4_LIST = "org.hibernate.collection.internal.PersistentList";
	protected static final String HIBERNATE_4_SET = "org.hibernate.collection.internal.PersistentSet";
	protected static final String HIBERNATE_4_MAP = "org.hibernate.collection.internal.PersistentMap";

	protected static final String JPA_ECLIPSE_LINK_COLLECTION = "org.eclipse.persistence.indirection.IndirectCollection";
	protected static final String JPA_ECLIPSE_LINK_LIST = "org.eclipse.persistence.indirection.IndirectList";
	protected static final String JPA_ECLIPSE_LINK_SET = "org.eclipse.persistence.indirection.IndirectSet";
	protected static final String JPA_ECLIPSE_LINK_MAP = "org.eclipse.persistence.indirection.IndirectMap";

	protected static final Class&lt;?&gt; PERSISTENT_COLLECTION = ClassLookup.find(JPA_ECLIPSE_LINK_COLLECTION, HIBERNATE_4_COLLECTION, HIBERNATE_3_COLLECTION).orThrow(new IllegalStateException("No supported persistence provider found")).get();
	protected static final Class&lt;?&gt; PERSISTENT_LIST = ClassLookup.find(JPA_ECLIPSE_LINK_LIST, HIBERNATE_4_LIST, HIBERNATE_3_LIST).orThrow(new IllegalStateException("No supported persistence provider found")).get();
	protected static final Class&lt;?&gt; PERSISTENT_SET = ClassLookup.find(JPA_ECLIPSE_LINK_SET, HIBERNATE_4_SET, HIBERNATE_3_SET).orThrow(new IllegalStateException("No supported persistence provider found")).get();
	protected static final Class&lt;?&gt; PERSISTENT_MAP = ClassLookup.find(JPA_ECLIPSE_LINK_MAP, HIBERNATE_4_MAP, HIBERNATE_3_MAP).orThrow(new IllegalStateException("No supported persistence provider found")).get();

	/**
	 * Returns {@code true} if Hibernate 3 collections are found in the classpath.
	 *
	 * @return {@code true} if Hibernate 3 is available, {@code false} otherwise
	 */
	public static boolean isHibernate3() {
		return getPersistentCollectionClass().getName().equals(HIBERNATE_3_COLLECTION);
	}

	/**
	 * Returns {@code true} if Hibernate 4 collections are found in the classpath.
	 *
	 * @return {@code true} if Hibernate 4 is available, {@code false} otherwise
	 */
	public static boolean isHibernate4() {
		return getPersistentCollectionClass().getName().equals(HIBERNATE_4_COLLECTION);
	}

	/**
	 * Returns {@code true} if EclipseLink collections are found in the classpath.
	 *
	 * @return {@code true} if EclipseLink is available, {@code false} otherwise
	 */
	public static boolean isEclipseLink() {
		return getPersistentCollectionClass().getName().equals(JPA_ECLIPSE_LINK_COLLECTION);
	}

	/**
	 * Returns the class used by Hibernate for representing a persistent collection.
	 *
	 * @return the persistent collection class
	 */
	@Nonnull
	public static Class&lt;?&gt; getPersistentCollectionClass() {
		return PERSISTENT_COLLECTION;
	}

	/**
	 * Returns the class that represents a persistent list.
	 *
	 * @return the persistent list class
	 */
	@Nonnull
	public static Class&lt;?&gt; getPersistentListClass() {
		return PERSISTENT_LIST;
	}

	/**
	 * Returns the class that represents a persistent set.
	 *
	 * @return the persistent set class
	 */
	@Nonnull
	public static Class&lt;?&gt; getPersistentSetClass() {
		return PERSISTENT_SET;
	}

	/**
	 * Returns the class that represents a persistent map.
	 *
	 * @return the persistent map class
	 */
	@Nonnull
	public static Class&lt;?&gt; getPersistentMapClass() {
		return PERSISTENT_MAP;
	}
}

  </pre>
</div>
<div id="footer">
Generated by <a href="http://code.google.com/p/doclava/">Doclava</a>.
</div> <!-- end footer -->

</div> <!-- jd-content -->

</div><!-- end doc-content -->

</div> <!-- end body-content --> 

<script type="text/javascript">
init(); /* initialize doclava-developer-docs.js */
</script>

</body>
</html>
